package com.xyzh05.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableId;
import org.compass.annotations.SearchableProperty;

@Entity
@Table(name="material_info")
@Searchable
@XmlRootElement
public class MaterialInfo extends BaseObject implements Serializable {
	private static final long serialVersionUID = -5810126857855332560L;
	
	private Long id;
    private Material material;
    private String toefl;
    private String gre;
    private String sat;
    private String ps;
    private String cv;
    private String rl;
    private String essay;
    private String applyUrl;
    private String applyCost;
    private String sendAddress;
    private Date applyEndTime;
    private Date applySubmitTime;
    private Date sendTime;

    @Id @GeneratedValue(strategy=GenerationType.AUTO) @SearchableId    
    public Long getId() {
        return this.id;
    }
    
    public void setId(Long id) {
        this.id = id;
    }

    @OneToOne(fetch=FetchType.LAZY)
    @JoinColumn(name="material_id", nullable=false)
    public Material getMaterial() {
        return this.material;
    }
    
    public void setMaterial(Material material) {
        this.material = material;
    }
    
    @Column(name="toefl", length=16)
    @SearchableProperty
    public String getToefl() {
        return this.toefl;
    }
    
    public void setToefl(String toefl) {
        this.toefl = toefl;
    }
    
    @Column(name="gre", length=16)
    @SearchableProperty
    public String getGre() {
        return this.gre;
    }
    
    public void setGre(String gre) {
        this.gre = gre;
    }
    
    @Column(name="sat", length=16)
    @SearchableProperty
    public String getSat() {
        return this.sat;
    }
    
    public void setSat(String sat) {
        this.sat = sat;
    }
    
    @Column(name="ps", length=16)
    @SearchableProperty
    public String getPs() {
        return this.ps;
    }
    
    public void setPs(String ps) {
        this.ps = ps;
    }
    
    @Column(name="cv", length=16)
    @SearchableProperty
    public String getCv() {
        return this.cv;
    }
    
    public void setCv(String cv) {
        this.cv = cv;
    }
    
    @Column(name="rl", length=16)
    @SearchableProperty
    public String getRl() {
        return this.rl;
    }
    
    public void setRl(String rl) {
        this.rl = rl;
    }
    
    @Column(name="essay", length=16)
    @SearchableProperty
    public String getEssay() {
        return this.essay;
    }
    
    public void setEssay(String essay) {
        this.essay = essay;
    }
    
    @Column(name="apply_url", length=256)
    @SearchableProperty
    public String getApplyUrl() {
        return this.applyUrl;
    }
    
    public void setApplyUrl(String applyUrl) {
        this.applyUrl = applyUrl;
    }
    
    @Column(name="apply_cost", length=16)
    @SearchableProperty
    public String getApplyCost() {
        return this.applyCost;
    }
    
    public void setApplyCost(String applyCost) {
        this.applyCost = applyCost;
    }
    
    @Column(name="send_address", length=512)
    @SearchableProperty
    public String getSendAddress() {
        return this.sendAddress;
    }
    
    public void setSendAddress(String sendAddress) {
        this.sendAddress = sendAddress;
    }
    
    @Column(name="apply_end_time")
    @SearchableProperty
    public Date getApplyEndTime() {
        return this.applyEndTime;
    }
    
    public void setApplyEndTime(Date applyEndTime) {
        this.applyEndTime = applyEndTime;
    }

    @Column(name="apply_submit_time")
    @SearchableProperty
    public Date getApplySubmitTime() {
		return applySubmitTime;
	}

	public void setApplySubmitTime(Date applySubmitTime) {
		this.applySubmitTime = applySubmitTime;
	}

    @Column(name="send_time")
    @SearchableProperty
	public Date getSendTime() {
		return sendTime;
	}

	public void setSendTime(Date sendTime) {
		this.sendTime = sendTime;
	}

	public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        MaterialInfo pojo = (MaterialInfo) o;

        if (material != null ? !material.equals(pojo.material) : pojo.material != null) return false;
        if (toefl != null ? !toefl.equals(pojo.toefl) : pojo.toefl != null) return false;
        if (gre != null ? !gre.equals(pojo.gre) : pojo.gre != null) return false;
        if (sat != null ? !sat.equals(pojo.sat) : pojo.sat != null) return false;
        if (ps != null ? !ps.equals(pojo.ps) : pojo.ps != null) return false;
        if (cv != null ? !cv.equals(pojo.cv) : pojo.cv != null) return false;
        if (rl != null ? !rl.equals(pojo.rl) : pojo.rl != null) return false;
        if (essay != null ? !essay.equals(pojo.essay) : pojo.essay != null) return false;
        if (applyUrl != null ? !applyUrl.equals(pojo.applyUrl) : pojo.applyUrl != null) return false;
        if (applyCost != null ? !applyCost.equals(pojo.applyCost) : pojo.applyCost != null) return false;
        if (sendAddress != null ? !sendAddress.equals(pojo.sendAddress) : pojo.sendAddress != null) return false;
        if (applyEndTime != null ? !applyEndTime.equals(pojo.applyEndTime) : pojo.applyEndTime != null) return false;
        if (applySubmitTime != null ? !applySubmitTime.equals(pojo.applySubmitTime) : pojo.applySubmitTime != null) return false;
        if (sendTime != null ? !sendTime.equals(pojo.sendTime) : pojo.sendTime != null) return false;

        return true;
    }

    public int hashCode() {
        int result = 0;
        result = (material != null ? material.hashCode() : 0);
        result = 31 * result + (toefl != null ? toefl.hashCode() : 0);
        result = 31 * result + (gre != null ? gre.hashCode() : 0);
        result = 31 * result + (sat != null ? sat.hashCode() : 0);
        result = 31 * result + (ps != null ? ps.hashCode() : 0);
        result = 31 * result + (cv != null ? cv.hashCode() : 0);
        result = 31 * result + (rl != null ? rl.hashCode() : 0);
        result = 31 * result + (essay != null ? essay.hashCode() : 0);
        result = 31 * result + (applyUrl != null ? applyUrl.hashCode() : 0);
        result = 31 * result + (applyCost != null ? applyCost.hashCode() : 0);
        result = 31 * result + (sendAddress != null ? sendAddress.hashCode() : 0);
        result = 31 * result + (applyEndTime != null ? applyEndTime.hashCode() : 0);
        result = 31 * result + (applySubmitTime != null ? applySubmitTime.hashCode() : 0);
        result = 31 * result + (sendTime != null ? sendTime.hashCode() : 0);

        return result;
    }

    public String toString() {
        StringBuffer sb = new StringBuffer(getClass().getSimpleName());

        sb.append(" [");
        sb.append("id").append("='").append(getId()).append("', ");
        sb.append("material").append("='").append(getMaterial()).append("', ");
        sb.append("toefl").append("='").append(getToefl()).append("', ");
        sb.append("gre").append("='").append(getGre()).append("', ");
        sb.append("sat").append("='").append(getSat()).append("', ");
        sb.append("ps").append("='").append(getPs()).append("', ");
        sb.append("cv").append("='").append(getCv()).append("', ");
        sb.append("rl").append("='").append(getRl()).append("', ");
        sb.append("essay").append("='").append(getEssay()).append("', ");
        sb.append("applyUrl").append("='").append(getApplyUrl()).append("', ");
        sb.append("applyCost").append("='").append(getApplyCost()).append("', ");
        sb.append("sendAddress").append("='").append(getSendAddress()).append("', ");
        sb.append("applyEndTime").append("='").append(getApplyEndTime()).append("'");
        sb.append("applySubmitTime").append("='").append(getApplySubmitTime()).append("'");
        sb.append("sendTime").append("='").append(getSendTime()).append("'");
        sb.append("]");
      
        return sb.toString();
    }

}
